{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution(object):\n",
    "    def intersect(self, nums1, nums2):\n",
    "        \"\"\"\n",
    "        :type nums1: List[int]\n",
    "        :type nums2: List[int]\n",
    "        :rtype: List[int]\n",
    "        \"\"\"\n",
    "        p1 = 0\n",
    "        p2 = 0\n",
    "        nums1.sort()\n",
    "        nums2.sort()\n",
    "        common = []\n",
    "        while p1 < len(nums1) and p2 < len(nums2):\n",
    "            if nums1[p1] == nums2[p2]:\n",
    "                common.append(nums1[p1])\n",
    "                p1 = p1 + 1\n",
    "                p2 = p2 + 1\n",
    "            elif nums1[p1] < nums2[p2]:\n",
    "                p1 = p1 + 1\n",
    "            elif nums1[p1] > nums2[p2]:\n",
    "                p2 = p2 + 1\n",
    "        return common"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = Solution()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "s.intersect()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
